package com.ruoyi.project.jsrh.news.controller;

import java.util.List;

import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.project.jsrh.news.domain.TMemDrawrecord;
import com.ruoyi.project.jsrh.news.service.ITMemDrawrecordService;
import com.ruoyi.project.system.user.domain.User;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 记录用户的详细提款信息Controller
 * 
 * @author ruoyi
 * @date 2020-06-15
 */
@Controller
@RequestMapping("/jsrh/drawrecord")
public class TMemDrawrecordController extends BaseController
{
    private String prefix = "jsrh/drawrecord";

    @Autowired
    private ITMemDrawrecordService tMemDrawrecordService;

    @RequiresPermissions("jsrh:drawrecord:view")
    @GetMapping()
    public String drawrecord()
    {
        return prefix + "/drawrecord";
    }

    /**
     * 查询记录用户的详细提款信息列表
     */
    @RequiresPermissions("jsrh:drawrecord:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TMemDrawrecord tMemDrawrecord)
    {
        startPage();
        List<TMemDrawrecord> list = tMemDrawrecordService.selectTMemDrawrecordList(tMemDrawrecord);
        return getDataTable(list);
    }

    /**
     * 导出记录用户的详细提款信息列表
     */
    @RequiresPermissions("jsrh:drawrecord:export")
    @Log(title = "记录用户的详细提款信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TMemDrawrecord tMemDrawrecord)
    {
        List<TMemDrawrecord> list = tMemDrawrecordService.selectTMemDrawrecordList(tMemDrawrecord);
        ExcelUtil<TMemDrawrecord> util = new ExcelUtil<TMemDrawrecord>(TMemDrawrecord.class);
        return util.exportExcel(list, "drawrecord");
    }

    /**
     * 新增记录用户的详细提款信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存记录用户的详细提款信息
     */
    @RequiresPermissions("jsrh:drawrecord:add")
    @Log(title = "记录用户的详细提款信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TMemDrawrecord tMemDrawrecord)
    {
        return toAjax(tMemDrawrecordService.insertTMemDrawrecord(tMemDrawrecord));
    }

    /**
     * 修改记录用户的详细提款信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        TMemDrawrecord tMemDrawrecord = tMemDrawrecordService.selectTMemDrawrecordById(id);
        mmap.put("tMemDrawrecord", tMemDrawrecord);
        return prefix + "/edit";
    }

    /**
     * 修改保存记录用户的详细提款信息
     */
    @RequiresPermissions("jsrh:drawrecord:edit")
    @Log(title = "记录用户的详细提款信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TMemDrawrecord tMemDrawrecord)
    {
        //填充操作者信息
        User currentUser = ShiroUtils.getSysUser();
        tMemDrawrecord.setOperatorid(currentUser.getUserId()+"");
        tMemDrawrecord.setOperator(currentUser.getUserName());
        return toAjax(tMemDrawrecordService.updateTMemDrawrecord(tMemDrawrecord));
    }

    /**
     * 删除记录用户的详细提款信息
     */
    @RequiresPermissions("jsrh:drawrecord:remove")
    @Log(title = "记录用户的详细提款信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tMemDrawrecordService.deleteTMemDrawrecordByIds(ids));
    }
}
